//声明: 该文件需要 swiper,jqueryui,common,toast,jquery

require(["config"], function(config) {
	require(["jquery.ui", "jquery", "sw", "toast", "my.hover","jPages"], function(jqui, jq, sw, t, mh,jPas) {
		$.get("header.html",function(data){
			$(".top_aa").append(data);
			$("#banner_left_bottom").css({"display":"none"});
			
					//菜单
					
		function creatCategory(data) {
			
			for(var i in data) {
				$('#banner_left_bottom').append("<div class='navleft'><a>" + data[i].aaa_1 + data[i].aaa_2 + "").append("<div class='nav-layer'>");
				for(var j in data[i].aaa_3) {
//									console.log(data[i].aaa_3[j])
					$('.nav-layer').last().append("<div class='ft'><dt><a>" + data[i].aaa_3[j].aaa_4_a + "");
					for(var k in data[i].aaa_3[j].aaa_4_b) {
						$('.ft').last().append("<dd><a>" + data[i].aaa_3[j].aaa_4_b[k] + "")
					}
				}
			}

			var navleft = document.getElementsByClassName("navleft");
			var navlayer = document.getElementsByClassName("nav-layer");
			for(let i = 0; i < navleft.length; i++) {
				navleft[i].onmouseover = function() {
					
					

					for(let j = 0; j < navleft.length; j++) {
						navleft[j].style.background = "#fff";
						navlayer[j].style.display = "none";
					}
					this.style.background = "#F5F5F5";
					navlayer[i].style.display = "block";
					$("#banner_left_bottom").css({"display":"block"})

					navlayer[i].onmouseleave = function() {
						navlayer[i].style.display = "none";
						navleft[i].style.background = "#fff";
						$("#banner_left_bottom").css({"display":"none"})
					}
					navlayer[i].onmouseover = function() {
						navlayer[i].style.display = "block";
						navleft[i].style.background = "#f5f5f5";
						$("#banner_left_bottom").css({"display":"block"})
					}
					navleft[i].onmouseleave = function() {
						navlayer[i].style.display = "none";
						navleft[i].style.background = "#fff";
						
					}
				}

			}
			$("#banner_left").css({"z-index":2,"height":"auto"})
			$("#banner_left_top").mouseover(function(){
				$("#banner_left_bottom").css({"display":"block"})
				
				$("#banner_left_top").mouseleave(function(){
					$("#banner_left_bottom").css({"display":"none"})
				})
			})
		}
		$.get("json1/banner.json", function(data) {
			creatCategory(data);
		})

		});
		

		function nvlist(data){
			for(var i in data){
				$(".nv_1").attr("src",data[i].pic1);
				$(".nv_2").attr("src",data[i].pic2);
				$(".nv_3").attr("src",data[i].pic3);
				$(".nv_4").attr("src",data[i].pic4);
				$(".nv_5").attr("src",data[i].pic5);
				$(".nv-jiage1a").html(data[i].xianjia);
				$(".nv-jiage2a").html(data[i].yuanjia);
				$(".nv_6").html(data[i].huodong);
				$('.nv_7').html(data[i].jieshi);
				
			$(".nv-z").last().clone().prependTo("#itemContainer");
		}
			
			}
			
		$.get("json1/nvzhuang.json",function(data){
			nvlist(data);
			 jq(".holder").jPages({
      containerID : "itemContainer",
     
      
    });
       $(".li1as").each(function(i){
       		$(this).mouseover(function(){
       			$(this).css({"opacity":0.7})
  		
  		console.log(i);
  		console.log($(this).parent().prev().children());
  		
  		$(this).parent().prev().children().attr("src","img/nv_list"+((i+4)%4+1)+".jpg")
  		
  		$(this).mouseleave(function(){
  			$(this).css({"opacity":1});
  		})
  		
  		
  	})
       })
  
		})
		

    /* initiate plugin */

	
	
		
	
		
		
		
		
		
		
		
		

		$.get("footer.html",function(data){
			$("body").last().append(data);
		})

	});

})